package com.it.rabbitmqwithjiang.Listener;

import com.it.rabbitmqwithjiang.Dao.MessageDao;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;


@Component
public class FanoutListener2 {
	@RabbitListener(queues = "fanoutqueue2")
	public void FanoutMessage(MessageDao messageDao, Channel channel, Message message) throws IOException {
		channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);  //这里一直会刷屏，因为消息一直没有被消费
		System.out.println("订阅者fanoutqueue2收到消息"+ messageDao.toString());
	}
}
